package com.codedancer.campus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.LostFoundItemComment;

public interface LostFoundItemCommentMapper extends BaseMapper<LostFoundItemComment> {

    /**
     * 分页查询某个物品的评论
     *
     * @param lostFoundItemCommentPage
     * @param lostFoundItemUuid
     * @return
     */
    default IPage<LostFoundItemComment> page(Page<LostFoundItemComment> lostFoundItemCommentPage,
        String lostFoundItemUuid) {
        LambdaQueryWrapper<LostFoundItemComment> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(LostFoundItemComment::getLostFoundItemUuid, lostFoundItemUuid);
        lambdaQueryWrapper.orderByDesc(LostFoundItemComment::getCreateTime);
        return selectPage(lostFoundItemCommentPage, lambdaQueryWrapper);
    }
}
